using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using MetroService.Host;
using Serilog;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Serilog.Events;

public class Program
{
    public static void Main(string[] args)
    {
        Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Debug()
            .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
            .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
            .Enrich.WithProperty("Application", "CommonService")
            .Enrich.FromLogContext()
            .WriteTo.File("Logs/logs.txt", rollingInterval: RollingInterval.Day)
            .CreateLogger();
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
                webBuilder.UseUrls("http://localhost:10004");
                webBuilder.UseKestrel(kestrel =>
                {
                    kestrel.ConfigureEndpointDefaults(options =>
                    {
                        options.Protocols = HttpProtocols.Http1AndHttp2;
                    });
                });
            })
            .UseAutofac()
            .UseSerilog();
}